﻿using System;

namespace 运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 算数运算符
            /*
            int number = 100;
            int number1 = 50;
            int result;
            int result1;
            int result2;
            int result3;
            result = number + number1;
            result1 = number - number1;
            result2 = number * number1;
            result3 = number / number1;
            Console.WriteLine(result);
            Console.WriteLine(result1);
            Console.WriteLine(result2);
            Console.WriteLine(result3);
            */
            #endregion

            #region 自增自减 ++  --
            /*
            int a = 10;
            int c = 20;
            Console.WriteLine(a++);//++在后面不参加实际运算，但最终会使当前数值加1
            Console.WriteLine(++a);//++在前面表示参与实际计算，从一开始就是原数值增加1来计算
            Console.WriteLine(a--);
            Console.WriteLine(--a);
            */

            #endregion

            #region  三元运算符
            /*
            //表达式 ？ 值一 : 值二
            int result = 0;
            result = 4 > 3 ? 1 : 0;
            Console.WriteLine(result);
            if (result == 0)//result==0
            {       
                Console.WriteLine("结果不正确");
            } else //result!=0
            {
                Console.WriteLine("结果正确");
            }
              */
            #endregion

            #region 赋值运算符
            /*
            int a = 10;
            a += 5; // a = a + 5 15
            a -= 5; // a = a - 5 10
            a *= 5; // a = a * 5 50
            a /= 5; // a = a / 5 5
            a %= 3; // a = a % 5 1
            Console.WriteLine(a);
            */
            #endregion

            #region   逻辑运算符
            /*
            int n = 12;
            int n1 = 22;
            int n2 = 199;
            
            //&& 与 表示两个条件都要满足才能执行
            if (n == 10 && n1 == 20 && n2 == 199)
            {
                Console.WriteLine("三个条件都满足");
            }
            // || 或 表示两个条件满足其一就可以执行。
            if(n == 10 || n1 == 20)
            {
                Console.WriteLine("两个条件满足其一");
            }
            if(n != 10)
            {
                Console.WriteLine("n的值！=10");
            }


            bool b1 = true;
            if (!b1)
            {
                Console.WriteLine("b1是true");
            }
            else
            {
                Console.WriteLine("b1是false");
            }*/
            #endregion

            #region  checked运算符 is运算符 as运算符
            //checked 如果代码有问题可以提示
            //checked checked checked checked checked checked checked checked checked checked checked chedked
            /* byte b = 255;
             checked
             {
                 b++;
                 Console.WriteLine(b);
             }
             unchecked//如果代码有问题。不提示会丢失代码原有值
             {
                 b++;
                 Console.WriteLine(b);
             }*/
            /*is 运算符 可以检查对象是否与特定的类型兼容
            object number = 10;
            if(number is int);
            {
                Console.WriteLine("object里面是整型类型");
            }
            int numbers = 101;
            if(number is object)
            {
                Console.WriteLine("int里面可以是object");
            }
            as 运算符 1-如果表达式2的值符合给定类型，则表达式1等于表达式2的值，否则，表达式1等于null
            //2-表达式1和表达式2必须是引用类型的变量或常量。
            object number = 10;
            //string str = number as string;
            // int a = number as int;
            int a1 = 20;
            object obj = a1 as object;            
            Console.WriteLine(obj);*/





            #endregion


            Console.ReadKey();
        }
    }
}
